/**
 * Witontek.com.
 * Copyright (c) 2012-2016 All Rights Reserved.
 */
package com.mxl.math;

/**
 * 
 * @author Long
 * @version $Id: T23div1.java, v 0.1 2016年12月2日 下午12:30:37  xiaolong.ma  Exp $
 */
public class T32plus2 {

    /**
     * 
     * @param args
     */
    public static void main(String[] args) {

        for (int i = 0; i < 1000; i++) {
            String s = "";
            for (int j = 0; j < 4; j++) {
                s += "  " + genNumStr(2, 2) + "  \t";
            }

            System.out.println(s);
        }
    }

    private static String genNumStr(int l1, int l2) {
        int i1 = genNum(l1, 2);
        int i2 = genNum(l2, 2);
        String op = " × ";
        return i1 + op + i2 + " =";
    }

    private static int genNum(int i) {
        return genNum(i, 1);
    }

    private static int genNum(int i, int len) {
        int r = 0;
        switch (i) {
            case 1:
                r = (int) (1 + Math.random() * 9);
                break;
            case 2:
                r = (int) (1 + Math.random() * 99);
                break;
            case 3:
                r = (int) (1 + Math.random() * 999);
                break;
            default:
                r = (int) (1 + Math.random() * 9);
        }

        String s = "" + r;
        if (s.length() < len) {
            return genNum(i);
        } else if (r == 1) {
            return genNum(i);
        } else {
            return r;
        }
    }

    private static String genOp() {
        int i = (int) (1 + Math.random() * 2);
        String r = "";
        switch (i) {
            case 1:
                r = " × ";
                break;
            case 2:
                r = " ÷ ";
                break;

            default:
                r = " × ";
        }

        return r;
    }
}
